package utils;

import java.util.regex.Pattern;

public class Regular {

    /*
    * 中英文通用模式
    * */
    public static Boolean rule(String name) {
        Boolean flag = false;
        String regexPattern = "^([\u4e00-\u9fa5]{2,10}|[A-Z][a-z]{1,19})(?:[·\\s-][\u4e00-\u9fa5A-Za-z]{2,20})*$";
        flag = Pattern.matches(regexPattern, name.trim());

        return flag;
    }

    /*
    * 整数
    * */
    public static Boolean rule_math(String number) {
        String regex = "^-?\\d{1,3}(?:,\\d{3})*\\.\\d+$|^-?\\d+\\.\\d+$";
        return Pattern.matches(regex, number);
    }
}
